package com.clms.maintain.controller;

import com.clms.common.R;
import com.clms.maintain.pojo.entity.TbShop;
import com.clms.maintain.pojo.vo.ShopVo;
import com.clms.maintain.service.ShopService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-third
 * @description:维修厂的实现层
 * @author: 许鹏
 * @create: 2021-07-23 10:17
 **/
@RestController
@RequestMapping("shop")
@ApiModel(value = "调用层", description = "维修厂的调用层")
public class ShopController {

    @Autowired
    @ApiModelProperty(value = "调用service层")
    private ShopService shopService;

    @GetMapping("selectListAll")
    @ApiModelProperty(value = "查询 下拉框")
    public R selectListAll(){
        return shopService.selectAllList();
    }


    @PostMapping("selectPage/{currentPage}/{pageSize}")
    @ApiModelProperty(value = "查询分页")
    public R selectShopAll(@PathVariable("currentPage") Integer currentPage, @PathVariable("pageSize") Integer pageSize, @RequestBody ShopVo shopVo){
        return shopService.selectShopAll(currentPage,pageSize,shopVo);
    }

    @PostMapping("insert")
    @ApiModelProperty(value = "新增维修厂")
    public R insertShop(@RequestBody TbShop tbShop){
        return shopService.insertShop(tbShop);
    }

    @PutMapping("update")
    @ApiModelProperty(value = "修改维修厂")
    public R updateShop(@RequestBody TbShop tbShop){
        return shopService.updateShop(tbShop);
    }

    @GetMapping("selectById/{id}")
    @ApiModelProperty(value = "通过id查询")
    public R selectById(@PathVariable Integer id){
        return shopService.selectById(id);
    }

    @DeleteMapping("delete/{id}")
    @ApiModelProperty(value = "删除")
    public R deleteById(@PathVariable Integer id){
        return shopService.deleteShop(id);
    }

    @PutMapping("updateStatus/{id}/{status}")
    @ApiModelProperty(value = "修改状态")
    public R updateStatus(@PathVariable Integer id,@PathVariable Integer status){
        return shopService.upStatus(id,status);
    }
}
